<div class="panel panel-default">
    <div class="panel-heading">
        回复内容
        <button type="button" ng-click="add()" class="btn btn-default btn-xs">添加回复</button>
    </div>
    <div class="panel-body">
        <div class="form-group" ng-repeat="(k,v) in contents"  style="position: relative;">
        <i class="fa fa-close delIcon" ng-click="delContent(k)"  style="position: absolute;cursor: pointer;z-index: 9;top: -7px;right: 10px;"></i>
            <label class="col-sm-2 control-label">内容</label>
            <div class="col-sm-10">
                <textarea ng-model="v.content" class="form-control" rows="3" required></textarea >
            </div>
        </div>
        <input type="text" name="content" hidden="hidden">
    </div>
</div>

<script>
    function module($scope) {
        var action = "<?php echo isset($answer)?'edit':'add'; ?>";
        if (action=='add') {
            $scope.contents = [{"content": ""}];
        } else {
            $scope.contents = <?php echo $answer['content']?:'[]';?>;
        }

        $scope.add = function () {
            $scope.contents.push({"content": ""});
        };
        $scope.delContent=function(k){
            $scope.contents=_.without($scope.contents,$scope.contents[k]);
        }
    }
    function submit($scope) {
        $("[name='content']").val(angular.toJson($scope.contents));
    }
</script>








